<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateUsersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('users', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('code',12)->unique();
            $table->string('name', 32);
            $table->string('avatar', 255)->nullable();
            $table->string('email', 64)->unique();
            $table->string('mobile', 16)->nullable()->index();
            $table->timestamp('email_verified_at')->nullable();
            $table->string('password');
            $table->rememberToken();
            // oauth provider
            $table->string('oauth_provider', 100)->nullable();
            $table->string('oauth_provider_id', 100)->nullable();
            $table->text('oauth_provider_token')->nullable();
            $table->dateTime('oauth_provider_expire_at')->nullable();
            // profile
            $table->boolean('revoked')->default(0);
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('users');
    }
}
